# 策略模式上下文
from simplefactory.cashnormal import CashNormal
from simplefactory.cashrebate import CashRebate
from simplefactory.cashreturn import CashReturn


class CashContext:
    cashSuper = None

    def __init__(self, type):
        if type == "满100减20":
            self.cashSuper = CashReturn(100, 20)
        elif type == "打八折":
            self.cashSuper = CashRebate(0.8)
        else:
            self.cashSuper = CashNormal()

    def getResult(self, money):
        return self.cashSuper.acceptCash(money)
